home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 9.0 KB | 294 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawSelection.h
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWSELECTION_H
- #define DRAWSELECTION_H
-
- #ifndef SHAPES_H
- #include "Shapes.h"
- #endif
-
- // ----- FrameWork Includes -----
-
- #ifndef FWSELECT_H
- #include <FWSelect.h>
- #endif
-
- // ----- OPF Foundation Includes -----
-
- #ifndef BCCOLLU_H
- #include "BCCollU.h"
- #endif
-
- #ifndef BCCOLLD_H
- #include "BCCollD.h"
- #endif
-
- // ----- Graphic Includes -----
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- //==============================================================================
- // •• Forward Declarations
- //==============================================================================
-
- class CDrawPart;
- class CDrawFrame;
- class FW_CFacet;
- class CSelectionIterator;
- class CDrawSelection;
- class FW_CGraphicContext;
- class BC_CUnmanaged;
-
- //==============================================================================
- // •• class CDrawPublishLink
- //==============================================================================
-
- class CDrawPublishLink : public FW_CPublishLink
- {
- public:
- enum
- {
- kChunkSize = 3 // Chunk size for publish links
- };
-
- CDrawPublishLink(XMPChangeID changeID, CDrawSelection *drawSelection);
- virtual ~ CDECL CDrawPublishLink();
-
- virtual void Publish();
- virtual void ExternalizeLinkContent(XMPStorageUnit* linkSU);
- virtual XMPValueType GetPublishFormat();
-
- private:
- CDrawSelection* fDrawSelection;
- BC_TDynamicCollection<CBaseShape*, BC_CUnmanaged>* fCollection;
- };
-
- //==============================================================================
- // •• class CDrawSubscribLink
- //==============================================================================
-
- class CDrawSubscribLink : public FW_CSubscribLink
- {
- public:
- enum
- {
- kChunkSize = 3 // Chunk size for subscribe links
- };
-
- CDrawSubscribLink(XMPLink *xmpLink, CDrawSelection *drawSelection);
- virtual ~CDrawSubscribLink();
-
- virtual void Subscrib();
-
- private:
- CDrawSelection* fDrawSelection;
- BC_TDynamicCollection<CBaseShape*, BC_CUnmanaged>* fCollection;
- };
-
- //==============================================================================
- // •• class CDrawSelection
- //==============================================================================
-
- class CDrawSelection : public FW_CSelection
- {
- //------------------------------------------------------------------------------
- // • Initialization/Destruction
- //
- public:
- CDrawSelection();
- void InitDrawSelection(CDrawPart* drawPart);
- virtual ~CDrawSelection();
-
- //------------------------------------------------------------------------------
- // • Inherited API
- //
- public:
- virtual void CloseSelection();
- virtual void SelectAll();
- virtual FW_Boolean IsEmpty() const;
- virtual FW_CProxyRun* IsSelectionOnlyOneProxyRun() const;
- virtual XMPShape* GetSelectionShape();
-
- // ----- Cut/Copy/Paste/Clear -----
- virtual FW_Boolean DoClear();
- virtual FW_Boolean DoPaste();
- virtual FW_Boolean DoPasteWithLink();
-
- virtual void ExternalizeSelection(XMPStorageUnit* storageUnit, FW_CFrame* commandFrame, XMPCloneKind kind);
- virtual FW_Boolean InternalizeSelection(XMPStorageUnit* storageUnit, XMPCloneKind kind);
- virtual FW_Boolean EmbedSelection(XMPPart* xmpPart, XMPShape* frameShape);
-
- // ----- Drag & Drop -----
- virtual XMPRgnHandle CalcDragRgn(FW_CFacet* facet);
- virtual FW_Boolean DoDroppedInSameFrame(XMPStorageUnit* dropSU, FW_CFacet* facet, const FW_CPoint& originPoint, const FW_CPoint& dropPoint);
- virtual FW_Boolean DoDrop(XMPStorageUnit* dropSU, FW_CFacet* facet, const FW_CPoint& originPoint, const FW_CPoint& dropPoint);
-
- // ----- Linking -----
- virtual FW_CPublishLink* NewPublishLink(XMPChangeID changeID);
- virtual FW_CSubscribLink* NewSubscribLink(XMPLink *xmpLink);
- virtual FW_Boolean IsSelectionPublishable();
-
- //------------------------------------------------------------------------------
- // • New API
- //
- public:
- CBaseShape* WhichHandle(FW_CFacet* facet, const FW_CPoint& mouse, short& whichHandle) const;
-
- void DrawSelectionHandles(FW_CFacet* facet, FW_Boolean turOn);
- void DrawHandles(CBaseShape* shape, FW_Boolean turOn);
- void DrawAllHandles(FW_CFrame* frame, FW_Boolean turOn);
-
- void AddToSelection(CBaseShape* theShape, FW_Boolean drawHandles);
- void RemoveFromSelection(CBaseShape* theShape, FW_Boolean drawHandles);
-
- void MapSelection(const FW_CRect& srcRect, const FW_CRect& dstRect);
- void OffsetSelection(XMPCoordinate xDelta, XMPCoordinate yDelta);
-
- void Resize(FW_CGraphicContext* gc, short whichHandle, const FW_CPoint& firstPoint, XMPEventData event);
-
- void SelectWithRectangle(FW_CFacet* facet, const FW_CPoint& anchorPoint, XMPEventData event);
-
- void ChangeSelectionPenSize(XMPCoordinate newPenSize);
- void ChangeSelectionFillFrame(unsigned short newFillFrame);
- void ChangeSelectionFillColor(const FW_CColor& color);
- void ChangeSelectionPenColor(const FW_CColor& color);
-
- FW_Boolean HasProxySelected() const;
-
- unsigned long Count() const;
-
- // ----- Frozen state -----
- FW_Boolean HasFrozen() const;
- FW_Boolean HasNotFrozen() const;
- void SetFrozen(FW_Boolean state);
-
- XMPShape* GetUpdateShape() const;
-
- // ----- Anchor Shape -----
- CBaseShape* GetAnchorShape() const;
- void SetAnchorShape(CBaseShape* anchorShape);
-
- // ----- Publish -----
- void SelectionChanged();
-
- // ----- Insert Menu Item -----
- virtual FW_Boolean InsertNewPart();
-
- // ----- Selection Collection -----
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* GetSelectionCollection() const;
-
- private:
- void DragFeedback(FW_PlatformRegion dragRgn, short xDelta, short yDelta);
-
- void CalcDragRect();
- void CalcUpdateShape();
- void CalcMapRect(short whichHandle, const FW_CPoint& handleCenter, XMPCoordinate penSize, FW_CRect* mapRect);
-
- void RedrawShape(CBaseShape *shape);
-
- void DoAdd(CBaseShape *shape);
- void DoRemove(CBaseShape *shape);
-
- void AdjustSelectionAfterPaste();
-
- //------------------------------------------------------------------------------
- // • Data Members
- //
- private:
- CDrawPart* fDrawPart;
- FW_CRect fDragRect;
- XMPShape* fSelectionShape;
- XMPShape* fUpdateShape;
- unsigned short fProxyShapeCount;
- unsigned short fFrozenCount;
- unsigned long fCount;
- CBaseShape* fAnchorShape;
-
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* fCollection;
- };
-
- //==============================================================================
- // •• CDrawSelection Inlines
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::HasProxySelected
- //------------------------------------------------------------------------------
- inline FW_Boolean CDrawSelection::HasProxySelected() const
- {
- return fProxyShapeCount != 0;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::GetUpdateShape
- //------------------------------------------------------------------------------
- inline XMPShape* CDrawSelection::GetUpdateShape() const
- {
- return fUpdateShape;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::HasFrozen
- //------------------------------------------------------------------------------
- inline FW_Boolean CDrawSelection::HasFrozen() const
- {
- return fFrozenCount != 0;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::HasNotFrozen
- //------------------------------------------------------------------------------
- inline FW_Boolean CDrawSelection::HasNotFrozen() const
- {
- return fCount != 0 && fFrozenCount != fCount;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::Count
- //------------------------------------------------------------------------------
- inline unsigned long CDrawSelection::Count() const
- {
- return fCount;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::GetAnchorShape
- //------------------------------------------------------------------------------
- inline CBaseShape* CDrawSelection::GetAnchorShape() const
- {
- return fAnchorShape;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::SetAnchorShape
- //------------------------------------------------------------------------------
- inline void CDrawSelection::SetAnchorShape(CBaseShape* anchorShape)
- {
- fAnchorShape = anchorShape;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawSelection::GetSelectionCollection
- //------------------------------------------------------------------------------
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* CDrawSelection::GetSelectionCollection() const
- {
- return fCollection;
- }
-
- #endif